package cn.tqfeiyang.smartadmin.business.organization.controller;

import cn.tqfeiyang.smartadmin.business.organization.constant.DepartmentConstants;
import cn.tqfeiyang.smartadmin.business.organization.service.DepartmentCacheService;

import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import cn.tqfeiyang.smartadmin.commons.response.ApiResult;
import cn.tqfeiyang.smartadmin.commons.logging.OperationLog;

/**
 * 部门缓存控制器
 *
 * @author tqfeiyang
 * @since 2024-10-18
 */
@RestController
@RequestMapping(DepartmentConstants.REQUEST_URL)
@Tag(name = DepartmentConstants.API_TAG)
public class DepartmentCacheController {

    /**
     * 部门缓存服务
     */
    @Resource
    private DepartmentCacheService departmentCacheService;

    /**
     * 清空部门缓存
     */
    @OperationLog
    @PostMapping("/clearCache")
    @Operation(summary = "部门 - 清空部门缓存")
    @SaCheckPermission(DepartmentConstants.PERMISSION + "clearCache")
    public ApiResult clearCache() {
        departmentCacheService.clearCache();
        return ApiResult.success();
    }
}
